import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";

@Entity("iot_device", { schema: "ztn_iot" })
export class Device {
    @PrimaryGeneratedColumn()
    deviceId: number;

    @Column({
        type: "varchar",
        length: 32,
        charset: "utf8",
        collation: "utf8_bin",
        comment: "设备码",
    })
    deviceCore: string;

    @Column({
        type: "varchar",
        length: 100,
        default: "",
        comment: "设备名称",
    })
    deviceName: string;

    @Column({
        type: "int",
        width: 10,
        default: 0,
    })
    userId: number;

    @Column({
        type: "int",
        width: 11,
        comment: "公司ID",
    })
    companyId: number;

    @Column({
        type: "int",
        width: 10,
        default: 0,
    })
    deptId: number;

    @Column({
        type: "int",
        width: 11,
        default: 0,
        comment: "省份Id",
    })
    provinceId: number;

    @Column({
        type: "int",
        width: 11,
        default: 0,
        comment: "城市ID",
    })
    cityId: number;

    @Column({
        type: "int",
        width: 10,
        default: 0,
    })
    serverId: number;

    @Column({
        type: "int",
        width: 11,
        default: 0,
        comment: "产品ID",
    })
    productId: number;

    @Column({
        type: "int",
        width: 50,
        comment: "系列ID",
    })
    seriesId: number;

    @Column({
        type: "smallint",
        default: 0,
        comment: "产品类型",
    })
    type: number;

    @Column({
        type: "varchar",
        length: 255,
        charset: "utf8",
        collation: "utf8_bin",
        default: "",
        comment: "icon",
    })
    iconUrl_del: string;

    @Column({
        type: "varchar",
        length: 255,
        default: "",
    })
    iconPath: string;

    @Column({
        type: "tinyint",
        width: 1,
        unsigned: true,
        default: 1,
        comment: "是否启动联网",
    })
    enable: number;

    @Column({
        type: "double",
        default: 0,
        comment: "纬度",
    })
    lat: number;

    @Column({
        type: "double",
        default: 0,
        comment: "经度",
    })
    lng: number;

    @Column({
        type: "varchar",
        length: 100,
        charset: "utf8",
        collation: "utf8_bin",
        default: "",
        comment: "地址",
    })
    address: string;

    @Column({
        type: "varchar",
        length: 20,
        charset: "utf8",
        collation: "utf8_bin",
        default: "UNACTIVE",
        comment: "在线状态",
    })
    status: string;

    @Column({
        type: "int",
        width: 11,
        default: 0,
        comment: "物联网卡状态",
    })
    phoneStatus: number;

    @Column({
        type: "varchar",
        length: 50,
        charset: "utf8",
        collation: "utf8_bin",
        default: "",
        comment: "物联网号码",
    })
    phoneNumber: string;

    @Column({
        type: "tinyint",
        width: 10,
        unsigned: true,
        default: 31,
        comment: "信号",
    })
    netSignal: number;

    @Column({
        type: "tinyint",
        width: 10,
        unsigned: true,
        default: 100,
        comment: "电量",
    })
    surplus: number;

    @Column({
        type: "tinyint",
        width: 1,
        unsigned: true,
        default: 0,
        comment: "充电中",
    })
    charging: number;

    @Column({
        type: "int",
        width: 10,
        default: 0,
        comment: "警报数",
    })
    warnNum: number;

    @Column({
        type: "varchar",
        length: 255,
        default: "",
    })
    imei: string;

    @Column({
        type: "tinyint",
        width: 1,
        unsigned: true,
        default: 0,
        comment: "是否可以联动",
    })
    canDeviceLinkage: number;


    @Column("json", { name: "rainFallSetting", nullable: true, comment: "雨量参数设置" })
    rainFallSetting: {devices:string[]; times:number; interval:number; dry:{offset:number; time:number}; rainy:{offset:number; time:number}};

    @Column({
        type: "int",
        width: 10,
        default: 0,
        comment: "创建时间",
    })
    createdDate: number;

    @Column({
        type: "int",
        width: 10,
        default: 0,
    })
    updateDate: number;

    @Column({
        type: "boolean"
    })
    deleteStatus: boolean;
}
